﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


using nplJobsCommon.Common;

namespace nplJobsDAL.Select
{
    public class SelectGender: DataAccessBase
    {
        public SelectGender()
        {
            StoredProcedureName = StoredProcedure.Name.spSelectGender.ToString();
        }

        #region GetGender
        public List<Gender> GetGender()
        {
            DataBaseHelper dbHelper;
            DataSet dsGender;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsGender = dbHelper.Run(base.ConnectionString);
                return GetList(dsGender);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<Gender> GetList(DataSet dsGender)
        {
            List<Gender> gender;
            try
            {
                gender = (from n in dsGender.Tables[0].AsEnumerable()
                                select new Gender
                                   {
                                       ID = n.Field<int>("ID"),
                                       GenderName = n.Field<string>("GenderName")
                                   }).ToList();

                return gender;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}
